package com.erp.erp_servers.CustomerComplaint.imp;

import com.erp.erp_dao.CustomerComplaint.ICustomerComplaintProductDAO;
import com.erp.erp_entitys.CustomerComplaint.ContractInfoVo;
import com.erp.erp_entitys.CustomerComplaint.CustomerComplaintProductEntity;
import com.erp.erp_servers.CustomerComplaint.ICustomerComplaintProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

@Service
public class ImpCustomerComplaintProductService implements ICustomerComplaintProductService {
    @Autowired
    private ICustomerComplaintProductDAO productDAO;
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return productDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(CustomerComplaintProductEntity record) {
        return productDAO.insert(record);
    }

    @Override
    public int insertSelective(CustomerComplaintProductEntity record) {
        return productDAO.insertSelective(record);
    }

    @Override
    public CustomerComplaintProductEntity selectByPrimaryKey(Integer id) {
        return productDAO.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(CustomerComplaintProductEntity record) {
        return productDAO.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(CustomerComplaintProductEntity record) {
        return productDAO.updateByPrimaryKey(record);
    }

    @Override
    public List<CustomerComplaintProductEntity> selectProductByCid(Integer cId) {
        return productDAO.selectProductByCid(cId);
    }

    @Override
    public PageInfo<ContractInfoVo> getContractList(ContractInfoVo cVo){
        List<ContractInfoVo> contractList = productDAO.getContractList(cVo);
        PageInfo pageInfo = new PageInfo(contractList);
        if(!CollectionUtils.isEmpty(contractList)){
            pageInfo.setList(contractList);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<CustomerComplaintProductEntity> getContractProductInfo(Integer id){
        List<CustomerComplaintProductEntity> proContractList = productDAO.getContractProductInfo(id);
        PageInfo pageInfo = new PageInfo(proContractList);
        if(!CollectionUtils.isEmpty(proContractList)){
            pageInfo.setList(proContractList);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<CustomerComplaintProductEntity> getProductInfoByContractIds(List<Integer> idList) {
        List<CustomerComplaintProductEntity> proContractList = productDAO.getProductInfoByContractIds(idList);
        PageInfo pageInfo = new PageInfo(proContractList);
        if(!CollectionUtils.isEmpty(proContractList)){
            pageInfo.setList(proContractList);
            return pageInfo;
        }
        return pageInfo;
    }

}
